<template>
  <div class="select-update-personaldata">
    <div class="titleArea">
      <p id="titleName">TIDC 科创管理中心</p>
    </div>
    <div id="essentialInformation">
      <div class="fristInformation">
        <p id="information">基本信息</p>
        <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="80px" class="demo-ruleForm">
          <el-form-item label="姓名" prop="studentName">
            <el-input v-model="ruleForm.studentName" placeholder="请输入姓名" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="学好" prop="studentID">
            <el-input v-model="ruleForm.studentID" placeholder="请输入学号" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="班级" prop="studentClass">
            <el-input v-model="ruleForm.studentClass" placeholder="请输入班级" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="性别" prop="studentSex" style="width:250px">
            <el-radio v-model="ruleForm.studentSex" label="1">男</el-radio>
            <el-radio v-model="ruleForm.studentSex" label="2">女</el-radio>
          </el-form-item>
          <el-form-item label="籍贯" prop="nativePlace">
            <el-input v-model="ruleForm.nativePlace" placeholder="请输入籍贯" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="权限" prop="Jurisdiction">
            <el-input v-model="ruleForm.Jurisdiction" placeholder="请输入权限" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="QQ号码" prop="QQNumber">
            <el-input v-model="ruleForm.QQNumber" placeholder="请输入QQ号码" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="方向" prop="studentDirection">
            <el-select v-model="ruleForm.studentDirection" placeholder="请选择">
              <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value">
              </el-option>
            </el-select>
          </el-form-item>
          <el-form-item label="微信号码" prop="weChatAccount">
            <el-input v-model="ruleForm.weChatAccount" placeholder="请输入微信号码" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="手机号码" prop="phoneNumber">
            <el-input v-model="ruleForm.phoneNumber" placeholder="请输入手机号码" class="inputLength"></el-input>
          </el-form-item>
          <el-form-item label="个人博客" prop="blogAddress">
            <el-input placeholder="请输入博客地址" v-model="ruleForm.blogAddress" style="width:280px;">
              <template slot="prepend" class="httpAddress">Http://</template>
            </el-input>
          </el-form-item>
          <el-form-item label="联系邮箱" prop="contactMailbox">
            <el-input placeholder="请输入联系邮箱" v-model="ruleForm.contactMailbox" style="width:280px;">
              <template slot="append">.com</template>
            </el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" @click="submitForm('ruleForm')">立即修改</el-button>
            <el-button @click="resetForm('ruleForm')">重置</el-button>
          </el-form-item>
        </el-form>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm: {
        studentName: "",
        studentID: "",
        studentClass: "",
        studentPassword: "",
        nativePlace: "",
        studentSex: "1",
        sureStudenPassword: "",
        studentDirection: "",
        Jurisdiction: "",
        phoneNumber: "",
        weChatAccount: "",
        QQNumber: "",
        blogAddress: "",
        contactMailbox: ""
      },
      options: [
        {
          value: "前端开发",
          label: "前端开发"
        },
        {
          value: "后端开发",
          label: "后端开发"
        },
        {
          value: "游戏开发",
          label: "游戏开发"
        },
        {
          value: "硬件开发",
          label: "硬件开发"
        },
        {
          value: "物联网开发",
          label: "物联网开发"
        },
        {
          value: "人工智能开发",
          label: "人工智能开发"
        },
        {
          value: "其他类型开发",
          label: "其他类型开发"
        }
      ],
      rules: {
        studentName: [
          { required: true, message: "请输入姓名", trigger: "blur" },
          {
            min: 3,
            max: 5,
            message: "名字长度在 3 到 5 个字符",
            trigger: "blur"
          }
        ],
        studentID: [
          { required: true, message: "请输入学号", trigger: "blur" },
          { min: 10, max: 10, message: "学号长度在10个字符", trigger: "blur" }
        ],
        studentClass: [
          { required: true, message: "请输入班级", trigger: "blur" },
          {
            min: 6,
            max: 10,
            message: "班级长度在 6 到 10 个字符",
            trigger: "blur"
          }
        ],
        studentPassword: [
          { required: true, message: "请输入密码", trigger: "blur" },
          {
            min: 6,
            max: 20,
            message: "密码长度在 6 到 20个字符",
            trigger: "blur"
          }
        ],
        nativePlace: [
          { required: true, message: "请输入籍贯", trigger: "blur" },
          {
            min: 6,
            max: 20,
            message: "籍贯长度在 6 到 20个字符",
            trigger: "blur"
          }
        ],
        studentDirection: [
          { required: true, message: "请输入选择方向", trigger: "blur" },
          {
            min: 4,
            max: 10,
            message: "籍贯长度在 4 到 10个字符",
            trigger: "blur"
          }
        ],
        studentSex: [
          { required: true, message: "请选择性别", trigger: "blur" },
          {
            min: 1,
            max: 3,
            message: "选认真选择性别",
            trigger: "blur"
          }
        ],
        sureStudenPassword: [
          { required: true, message: "请输入确认密码", trigger: "blur" },
          {
            min: 6,
            max: 20,
            message: "密码长度在 6 到 20个字符",
            trigger: "blur"
          }
        ],
        Jurisdiction: [
          { required: true, message: "请输入权限", trigger: "blur" },
          {
            min: 4,
            max: 10,
            message: "权限长度在 4 到 10个字符",
            trigger: "blur"
          }
        ],
        phoneNumber: [
          { required: true, message: "请输入手机号码", trigger: "blur" },
          {
            min: 11,
            max: 11,
            message: "手机号码长度在11个字符",
            trigger: "blur"
          }
        ],
        weChatAccount: [
          { required: true, message: "请输入微信账号", trigger: "blur" },
          {
            min: 5,
            max: 20,
            message: "微信账号长度在 5 到 20个字符",
            trigger: "blur"
          }
        ],
        QQNumber: [
          { required: true, message: "请输入QQ号码", trigger: "blur" },
          {
            min: 9,
            max: 10,
            message: "QQ号码长度在 9 到 10个字符",
            trigger: "blur"
          }
        ],
        blogAddress: [
          { required: true, message: "请输入博客地址", trigger: "blur" },
          {
            min: 10,
            max: 100,
            message: "地址长度在 10 到 100个字符",
            trigger: "blur"
          }
        ],
        contactMailbox: [
          { required: true, message: "请输入联系邮箱", trigger: "blur" },
          {
            min: 10,
            max: 50,
            message: "联系邮箱长度在10~50位",
            trigger: "blur"
          }
        ]
      }
    };
  },
  methods: {
    submitForm(formName) {
      this.$refs[formName].validate(valid => {
        if (valid) {
          alert("submit!");
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    resetForm(formName) {
      this.$refs[formName].resetFields();
    }
  }
};
</script>

<style scoped>
.el-form-item {
  font-weight: bold;
  height: 45px;
  float: left;
  margin-left: 20px;
}
.httpAddress {
  height: 45px;
}
.el-select {
  margin-left: 10px;
}
.el-input {
  margin-left: 10px;
}

#fristHeader {
  width: 100%;
  height: 350px;
}

.inputLength {
  width: 280px;
}
.titleArea {
  width: 1000px;
  margin: 0 auto;
  color: #3b3b3b;
  height: 30px;
  font-weight: bold;
  padding-top: 40px;
  padding-bottom: 20px;
  background-color: #ffffff;
}

.titleArea #titleName {
  opacity: 0.7;
  color: #3b3b3b;
  margin: 0px auto;
  font-size: 16px;
}

#essentialInformation {
  width: 1000px;
  margin: 0 auto;
  padding-top: 5px;
  background-color: #ffffff;
}

.fristInformation {
  width: 850px;
  margin: 0px auto;
  background-color: #ffffff;
}

#information {
  height: 26px;
  opacity: 0.8;
  font-size: 15px;
  color: #3b3b3b;
  text-align: left;
  font-weight: bold;
  letter-spacing: 2px;
  border-bottom: 1px dashed #b3b3b3;
}
.el-button {
  width: 180px;
  margin-left: 65px;
  margin-right: 65px;
}
</style>
